<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>donw2-多文件演示页面</title>
    <script type="text/javascript" src="js/jquery-1.4.min.js"></script>
    <script type="text/javascript" src="js/down.js" charset="utf-8"></script>
    <script type="text/javascript" src="js/demo.js" charset="utf-8"></script>
    <style type="text/css">
        h5 {margin:0;font-family: 微软雅黑 宋体;}
        p {font: 9pt 宋体;}
        ul {list-style-type: none;font: 9pt 宋体;}
        ul li {display: inline;margin: 0 5px 0 0;font: 9pt 宋体;}
    </style>
</head>
<body>
    <h5>此页面演示单个URL文件下载。</h5>
    <div id="demos"></div>
    <input type="button" value="url文件下载测试" id="btn-down" />
    <div id="downDiv"></div>
    <script type="text/javascript" language="javascript">
	    //根路径：http://localhost/api/up6/
	    var pos = window.location.href.lastIndexOf("index.htm");
	    var api = window.location.href.substr(0, pos)+"db/";
	    var downer = new DownloaderMgr({
	        config: {
	            License2:"",//请在此处配置授权码
	            Folder: "",
	            DataBase: false,//启用数据库支持
	            //api
	            "UrlCreate": api + "d_create.jsp",
	            "UrlDel": api + "d_del.jsp",
	            "UrlList": api + "d_list.jsp",
	            "UrlUpdate": api + "d_update.jsp",
	            "UrlDown": api + "down.jsp"
	        },
	        event: {
	            taskCreate: function (f) {
	                $(document.body).append("<div>文件ID：" + f.fileSvr.id) + "</div>";

                    setTimeout(function () {
                        if (f.fields.auto=="1") downer.start_queue();
                    }, 300);
	            },
	            downProcess: function (obj) { },
	            downStoped: function (obj) { },
	            downComplete: function (obj) {
	                $(document.body).append('<div>本地路径：' + obj.fileSvr.pathLoc + '</div>');
	            },
	            downError: function (obj, err) { },
	            queueComplete: function () {
	                $(document.body).append('<div>队列完成</div>');
                },
	            //ready: function () { },
	            selFolder: function (dir) {
                    setTimeout(function(){
                        if(downer.data.cur!=null)
                        {
                            downer.addUrl(downer.data.cur);
                            downer.data.cur = null;
                        }
                    },100);
                }
	        },
	        ui: { render:"downDiv"}
	    });

        $(function () {
            $("#btn-down").click(function () {
                var f = { fileUrl: "http://www.ncmem.com/images/ico-ftp.jpg" ,
                    fields:{auto:"1"}
                };

                if (downer.Config["Folder"] == "") {
                    downer.data.cur = f;
                    downer.openFolder();
                    return;
                }

                downer.addUrl(f);
            });
        });
    </script>
</body>
</html>